package a2_linkedlist.singlelinkedlist;

public class TestSingleLinkedListWithHead {
    public static void main(String[] args) {
        SingleLinkedListWithHead sk = new SingleLinkedListWithHead();
        /****  添加  ***********/
        sk.addFirst(3);
        sk.addFirst(2);
        sk.addFirst(1);
        //1 -> 2 -> 3 -> NULL
        //System.out.println(sk);
        sk.addLast(4);
        //1 -> 2 -> 3 -> 4 -> NULL
        //System.out.println(sk);
        sk.addIndex(2,5);
        //1 -> 2 -> 5 -> 3 -> 4 -> NULL

        System.out.println(sk);
        /****  删除  ***********/
        sk.removeIndex(1);
        //1 -> 5 -> 3 -> 4 -> NULL
        System.out.println(sk);
        sk.addLast(3);
        //1 -> 5 -> 3 -> 4 -> 3 -> NULL
        System.out.println(sk);
        sk.removeOnceValue(3);
        //1 -> 5 -> 4 -> 3 -> NULL
        System.out.println(sk);
        sk.addLast(1);
        sk.addLast(1);
        //1 -> 5 -> 4 -> 3 -> 1 -> 1 -> NULL
        System.out.println(sk);
        sk.removeAllValue(1);
        //5 -> 4 -> 3 -> NULL
        System.out.println(sk);
        System.out.println("元素个数为 "+sk.size());

        /****  修改  ***********/
        sk.set(0,1);
        //1 -> 4 -> 3 -> NULL
        System.out.println(sk);

        /****  查找  ***********/
        System.out.println("索引为1的元素值为"+sk.get(1));
        System.out.println("链表中有无值为5的元素: "+sk.contains(5));
    }
}
